package LazyInnerClassSingleton;

import java.lang.reflect.Constructor;

/**
 * @program: homeWork
 * @description: 反射破坏单例
 * @author: hezhiqin
 * @create: 2019-09-25 08:35
 */
public class LazyInnerClassSingletonTest {

    public static void main(String[] args) {
        //很无聊的情况下，进行破坏
        Class<?> clazz = LazyInnerClassSingleton.class;

        //通过反射拿到私有的构造方法
        try {
            Constructor c = clazz.getDeclaredConstructor(null);
            c.setAccessible(true);
            //暴力初始化
            Object o1 = c.newInstance();
            Object o2 = c.newInstance();
            System.out.println(o1 == o2);
        } catch (Exception e) {
            e.printStackTrace();
        }


    }
}
